package info.nene_loveplus.controller.admin;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public abstract class AbstractAdminController extends Controller {

	private UserService userService = UserServiceFactory.getUserService();

	@Override
	protected Navigation run() throws Exception {

		if (userService.isUserLoggedIn() && userService.isUserAdmin()) {
			return doRun();
		} else {
			return redirect(userService.createLoginURL("/admin/"));
		}
	}

	public abstract Navigation doRun() throws Exception;

}
